﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;
using System.Data;

public partial class TravelDocInfo : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly NewsBLL bllNews = new NewsBLL();
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly PicturesBLL bllPictures = new PicturesBLL();

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["Key"] != null)
                {
                    int id = Int32.Parse(Request.QueryString["Key"].ToString());
                    InitData(id);
                }
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
            Response.Redirect("TravelDoc.aspx", false);
        }
    }
    #endregion

    #region 绑定
    private void InitData(int id)
    {
        TFXK.Model.News model = bllNews.GetModel(id);
        this.Title = model.title + "-下一站-下驿栈旅游网";
        lblTitle.Text = model.title;
        lblContent.Text = model.description;
        lblPubDate.Text = model.createTime + "";
        lblReadCount.Text = model.clicks + "";
        lblpubuser.Text = model.publisher;
		lblsource.Text = model.source;
        bllNews.UpdateClick(model.id);
        try
        {
            string code = bllCategory.GetModel(model.parentId).codeNo;
            SetImgNav(code);
            Pictures pmodel = bllPictures.GetModel(model.id, model.parentId);
            if (pmodel != null)
            {
                imgContent.ImageUrl = "uploads/" + pmodel.imgPath;
                imgContent.Visible = true;
            }
            else
            {
                imgContent.Visible = false;
            }
        }
        catch
        {

        }


    }
    #endregion



    public void SetImgNav(string code)
    {
        if (code.Equals("lyxx"))
        {
            imgNav.ImageUrl = "images/lyxx.jpg";
        }
        else if (code.Equals("lysx"))
        {
            imgNav.ImageUrl = "images/lysx.jpg";
        }
        else if (code.Equals("lygl"))
        {
            imgNav.ImageUrl = "images/lygl.jpg";
        }
        else if (code.Equals("lycjwt"))
        {
            imgNav.ImageUrl = "images/cjwt.jpg";
        }
        else if (code.Equals("xxss"))
        {
            imgNav.ImageUrl = "images/xxss.jpg";
        }
    }
}
